<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>完美的居中</title>
</head>
<style>

.flex-container {
	display: -webkit-flex;
	display: flex;
	flex-direction: row;
	width: 400px;
	height: 350px;
	background-color: lightgrey;
}

.flex-item {
	background-color: cornflowerblue;
	width: 100px;
	height: 100px;
	margin: auto;
}

</style>
<body>

使用弹性盒子，居中变的很简单，只需要设置 margin: auto; 可以使得弹性子元素在两上轴方向上完全居中<br><br>

<div class="flex-container">
	<div class="flex-item">flex item 1</div>
	<!-- <div class="flex-item">flex item 2</div> -->
</div>

</body>
</html>
